#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;
typedef double db;
inline int read()
{
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9') { if(ch=='-')f=-1; ch=getchar(); }
	while(ch>='0'&&ch<='9') { x=(x<<1)+(x<<3)+ch-'0'; ch=getchar(); }
	return x*f;
}
const int MAXN=;
int n,f[MAXN][MAXN];
char a[MAXN];
int main()
{
	scanf("%s",a+1);
	n=strlen(a+1);
	for(int i=1;i<=n;++i)f[i][i]=1;
	for(int l=2;l<=n;++l)
		for(int i=1;i+l-1<=n;++i)
		{
			int j=i+l-1;
			if(a[i]==a[j])f[i][j]=f[i+1][j-1]+2;
			else f[i][j]=max(f[i+1][j],f[i][j-1]);
		}
	printf("%d\n",f[1][n]);
	return 0;
}
